package a.b.mvc6.service;

import a.b.mvc6.mapper.StudentsMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class MyAsync {
    @Autowired
    private StudentsMapper studentsMapper;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Async
    public void asyncMethod() {
        studentsMapper.selectByPrimaryKey(2L);
        String giao = stringRedisTemplate.opsForValue().get("giao");
        log.info("giao的值为：{}", giao);
        log.info("异步任务结束！");
    }
}
